from PIL import Image


async def generate_thumb(filepath, max_size=120):
    new_stem = f"{filepath.stem}-x{max_size}"
    with Image.open(filepath) as img:
        img.thumbnail((max_size, max_size))
        thumb_path = filepath.with_stem(new_stem)
        img.save(thumb_path)
    return new_stem
